package com.jams.goodox.activity.mine.interaction;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.activity.mine.view.KindredView;
import com.jams.goodox.adapter.CustomPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by Jin on 2016/7/5.
 * Description 我的互动
 */
public class MineInteractionActivity extends BaseActivity {

	@Bind(R.id.kindredView)
	KindredView kindredView;
	@Bind(R.id.viewPager)
    ViewPager viewPager;

	private List<Fragment> fragmentList;

	@Override
	protected int getLayoutId() {
		return R.layout.mine_interaction;
	}

	@Override
	protected void init() {
		setTitleVisibility(false);
		fragmentList = new ArrayList<>(2);
		//我发布的
		MinePublishFragment fragment1 = new MinePublishFragment();
		//我参与的
		Fragment fragment2 = new MineInteractionJoinFragment();

		fragmentList.add(fragment1);
		fragmentList.add(fragment2);

		viewPager.setAdapter(new CustomPagerAdapter(getSupportFragmentManager(), fragmentList));

		viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
			@Override
			public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

			}

			@Override
			public void onPageSelected(int position) {
				kindredView.setFocus(mContext, position);
			}

			@Override
			public void onPageScrollStateChanged(int state) {

			}
		});
		kindredView.addKindredClickListener(new KindredView.KindredClickListener() {
			@Override
			public void addKindredClickListener(int position) {
				viewPager.setCurrentItem(position);
			}
		});
	}

	@OnClick(R.id.back)
	public void onClick() {
		finish();
	}
}
